home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
bstring
/
RCS
/
bzero.c,v
< prev
next >
Wrap
Text File
|
1992-05-14
|
6KB
|
280 lines
head 1.7;
branch ;
access ;
symbols sprited:1.6.1;
locks ; strict;
comment @ * @;
1.7
date 92.05.14.18.56.24; author kupfer; state Exp;
branches ;
next 1.6;
1.6
date 91.03.24.19.03.13; author kupfer; state Exp;
branches 1.6.1.1;
next 1.5;
1.5
date 90.09.11.14.13.22; author kupfer; state Exp;
branches ;
next 1.4;
1.4
date 89.01.26.12.48.53; author ouster; state Exp;
branches ;
next 1.3;
1.3
date 88.11.28.09.28.41; author rab; state Exp;
branches ;
next 1.2;
1.2
date 88.07.19.13.26.48; author mendel; state Exp;
branches ;
next 1.1;
1.1
date 88.04.25.21.39.27; author ouster; state Exp;
branches ;
next ;
1.6.1.1
date 91.12.02.21.28.26; author kupfer; state Exp;
branches ;
next ;
desc
@@
1.7
log
@Remove debugging check for incorrect access to user addresses. Use
the ANSI signature (void pointers, etc).
@
text
@/*
* bzero.c --
*
* Source code for the "bzero" library routine.
*
* Copyright 1988 Regents of the University of California
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#ifndef lint
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.6 91/03/24 19:03:13 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)";
#endif not lint
#include <bstring.h>
#include <machparam.h>
/*
* The following mask is used to detect proper alignment of addresses
* for doing word operations instead of byte operations. It is
* machine-dependent. If none of the following bits are set in an
* address, then word-based operations may be used. This value is imported
* from machparam.h
*/
#define WORDMASK WORD_ALIGN_MASK
/*
*----------------------------------------------------------------------
*
* bzero --
*
* Clear a block of memory to zeroes. This routine is optimized
* to do the clear in integer units, if the block is properly
* aligned.
*
* Results:
* Nothing is returned. The memory at destPtr is cleared.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
bzero(destVoidPtr, numBytes)
_VoidPtr destVoidPtr; /* Where to zero. */
register int numBytes; /* How many bytes to zero. */
{
register int *dPtr = (int *) destVoidPtr;
char *destPtr = destVoidPtr;
/*
* If the address is on an aligned boundary then zero as much
* as we can in big transfers (and also avoid loop overhead by
* storing many zeros per iteration). Once we have less than
* a whole int to zero then it must be done by byte zeroes.
*/
if (((int) dPtr & WORDMASK) == 0) {
while (numBytes >= 16*sizeof(int)) {
dPtr[0] = 0;
dPtr[1] = 0;
dPtr[2] = 0;
dPtr[3] = 0;
dPtr[4] = 0;
dPtr[5] = 0;
dPtr[6] = 0;
dPtr[7] = 0;
dPtr[8] = 0;
dPtr[9] = 0;
dPtr[10] = 0;
dPtr[11] = 0;
dPtr[12] = 0;
dPtr[13] = 0;
dPtr[14] = 0;
dPtr[15] = 0;
dPtr += 16;
numBytes -= 16*sizeof(int);
}
while (numBytes >= sizeof(int)) {
*dPtr++ = 0;
numBytes -= sizeof(int);
}
if (numBytes == 0) {
return;
}
destPtr = (char *) dPtr;
}
/*
* Zero the remaining bytes
*/
while (numBytes > 0) {
*destPtr++ = 0;
numBytes--;
}
}
@
1.6
log
@Small hack so that the kernel can check for incorrect references to
user addresses.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.5 90/09/11 14:13:22 kupfer Exp Locker: kupfer $ SPRITE (Berkeley)";
d20 3
a30 2
#include "machparam.h"
a32 4
#ifdef KERNEL
#include <vmHack.h>
#endif
d52 2
a53 2
bzero(destPtr, numBytes)
char *destPtr; /* Where to zero. */
d56 2
a57 5
register int *dPtr = (int *) destPtr;
#ifdef VM_CHECK_BSTRING_ACCESS
Vm_CheckAccessible(destPtr, numBytes);
#endif
@
1.6.1.1
log
@Initial branch for Sprite server.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.6 91/03/24 19:03:13 kupfer Exp $ SPRITE (Berkeley)";
@
1.5
log
@Lint.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.4 89/01/26 12:48:53 ouster Exp Locker: kupfer $ SPRITE (Berkeley)";
d32 4
d60 4
@
1.4
log
@Change return value back to <empty> for UNIX compatibility.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.3 88/11/28 09:28:41 rab Exp Locker: ouster $ SPRITE (Berkeley)";
d50 1
@
1.3
log
@Changed return value to void.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: /sprite/src/lib/c/bstring/RCS/bzero.c,v 1.2 88/07/19 13:26:48 mendel Exp Locker: rab $ SPRITE (Berkeley)";
a49 1
void
@
1.2
log
@Import WORD_ALIGN_MASK from machparam.h.
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: bzero.c,v 1.1 88/04/25 21:39:27 ouster Exp $ SPRITE (Berkeley)";
d50 1
d56 1
a56 1
@
1.1
log
@Initial revision
@
text
@d17 1
a17 1
static char rcsid[] = "$Header: bzero.c,v 1.1 88/04/25 13:25:41 ouster Exp $ SPRITE (Berkeley)";
d24 2
a25 2
* address, then word-based operations may be used. Eventually this
* mask needs to be handled in a more machine-independent fashion.
d28 4
a31 1
#define WORDMASK 0x1
@